<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <title>会员页面</title>
    <link href='fullcalendar/core/main.css' rel='stylesheet' />
    <link href='fullcalendar/daygrid/main.css' rel='stylesheet'/>
    <script src='fullcalendar/core/main.js'></script>
    <script src='fullcalendar/daygrid/main.js'></script>

    <!-- 1. 导入CSS的全局样式 -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <!-- 2. jQuery导入，建议使用1.9以上的版本 -->
    <script src="js/jquery-3.3.1.min.js"></script>
    <!-- 3. 导入bootstrap的js文件 -->
    <script src="js/bootstrap.min.js"></script>
    <script>
        $(function () {
            $.get("findEmp",function (data) {
                var s= "欢迎您，"+data.name;
                $("#name").html(s);
            });

            $("#search").click(function () {
                var search = location.search;
                var empId = search.split("=")[1];
                location.href="empcheckwork.html?empId="+empId;
            });

            $.get("findCheck",function (data) {
                if(data.flag){
                    $("#start").attr("disabled","disabled");
                    $("#start").html(data.errorMsg);
                    if(data.data!=null){
                        $("#end").html(data.data);
                    }
                }else {
                    $("#end").attr("disabled","disabled");
                }
            });
            $("#start").click(function () {
                load();
            });
            $("#end").click(function () {
                load();
            });

            /*$("#check").click(function () {
                load();
            });
*/
            function load() {
                var search = location.search;
                var empId = search.split("=")[1];
                //alert(empId)
                $.get("checkWork",{empId:empId},function (data) {
                    if(data.flag){
                        location.reload();
                    }else{
                        alert("尚未登录，请先登录！");
                        location.href="login.html";
                    }
                });
            }
        });
        document.addEventListener('DOMContentLoaded', function() {
            var calendarEl = document.getElementById('calendar');
            var calendar = new FullCalendar.Calendar(calendarEl, {
                plugins: [ 'dayGrid' ],
                events: {
                    url:'calendar',
                    startParam:"begin",
                    method:"get",
                    color:"white",
                    textColor:"green"
                }
            });
            calendar.render();
        });
    </script>
</head>
<body>
    <div class="container" >
        <div class="row">
            <div class="masthead">
                <h3 class="text-muted" id="name">欢迎您，朱万顺</h3>
                <nav>
                    <ul class="nav nav-justified">
                        <a href="Canendar.html" target="main-ifr"><button type="button" class="btn btn-success" id="start">上班打卡</button></a>
                        <a href="Canendar.html" target="main-ifr"><button type="button" class="btn btn-success" id="end">下班打卡</button></a>
                        <!--<li id="check"><a href="#" id="info">考勤</a></li>-->
                        <li id="search"><a href="empcheckwork.html" target="main-ifr">查看考勤</a></li>
                        <li id="setpassword"><a href="updatePassword.html" target="main-ifr">修改密码</a></li>
                        <li><a href="#">修改个人信息</a></li>
                        <li id="exit"><a href="exit">退出登录</a></li>
                        <li class="right"><a href="#">关于我们</a></li>
                    </ul>
                </nav>
            </div>
        </div>
        <div class="row">
            <div class="col-md-12">
                <div class="col-md-12">
                    <iframe src="Canendar.html" name="main-ifr" style="width: 100%; height: 600px; border: 2px solid blue"></iframe>
                </div>
            </div>
        </div>
    </div>
</body>
</html>